-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize EOF by reading types on demand #1034
Optimize EOF by reading types on demand #1034
Conversation
This PR addresses: #1003 |
lib/evmone/eof.cpp
Outdated
if (type_section_size != code_sizes.size() * 4) | ||
return EOFValidationError::invalid_type_section_size; | ||
|
||
auto validation_error = validate_types(container, type_section_offset, type_section_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite an issue: validate_type()
should not be used in validate_header()
and invoke separately after validate_header()
. This way we can just pass EOF1Header
to validate_types()
and use its .get_type()
method.
But maybe this requires a separate PR. What do you think @gumb0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to try in a separate PR.
It made sense to do it here before, becase "validate header" really meant "validate header and types and return them togethere in one struct"
lib/evmone/eof.hpp
Outdated
@@ -43,6 +61,11 @@ struct EOF1Header | |||
/// The EOF version, 0 means legacy code. | |||
uint8_t version = 0; | |||
|
|||
/// Size of every type section. | |||
uint16_t type_section_size = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to store the size at all, because header validation guarantees that type_section_size == code_sizes.siz() * 4
85d4bed
to
b8de2e6
Compare
09de4f8
to
a54e9a5
Compare
Introduces `EOF1Header::get_type` function to read individual EOF code types. This is fast procedure because we need to read at most 4 bytes and a know offset. By doing so we avoid allocating separated vector to types.
a54e9a5
to
21a78e3
Compare
Introduces
EOF1Header::get_type
function to read individual EOFcode types. This is fast procedure because we need to read at most 4
bytes and a know offset. By doing so we avoid allocating separated
vector to types.
Closes #1003.